﻿using ReactiveUI;
using System.Reactive.Disposables;
using System.Windows;

namespace ScienceAIApp.Views.SubViews
{
    /// <summary>
    /// Interaction logic for PatientSeriesView.xaml
    /// </summary>
    public partial class PatientSeriesView
    {
        public PatientSeriesView()
        {
            InitializeComponent();
            this.WhenActivated(_activated);
        }

        private void _activated(CompositeDisposable disposable)
        {
            // 宽度属性绑定
            //this.OneWayBind(
            //        ViewModel,
            //        vm => vm.Width,
            //        v => v.Width)
            //    .DisposeWith(disposable);

            // 序列名称绑定
            this.OneWayBind(
                    ViewModel,
                    vm => vm.ShowDescription,
                    v => v.ShowDescription.Text)
                .DisposeWith(disposable);

            this.OneWayBind(
                    ViewModel,
                    vm => vm.IsHistory,
                    v => v.ChooseBorder.Visibility,
                    isHis => isHis ? Visibility.Collapsed : Visibility.Visible)
                .DisposeWith(disposable);

            this.OneWayBind(
                    ViewModel,
                    vm => vm.IsHistory,
                    v => v.DeleteBorder.Visibility,
                    isHis => isHis ? Visibility.Visible : Visibility.Collapsed)
                .DisposeWith(disposable);

            this.OneWayBind(
                    ViewModel,
                    vm => vm.IsChecked,
                    v => v.ChooseImg.Visibility,
                    isCheck => isCheck ? Visibility.Visible : Visibility.Collapsed)
                .DisposeWith(disposable);

            //PatientSeriesBorder

            this.BindCommand(
                    ViewModel,
                    vm => vm.ChooseSeriesCommand,
                    v => v.PatientSeriesBorder,
                    nameof(PatientSeriesBorder.MouseDown))
                .DisposeWith(disposable);
        }
    }

}
